package com.wz.jiangsu.main.vav;

/**
 * @author wangzhou
 * @version 1.0
 * @date 2025/3/26 19:30
 */
public class TestA {
    public static void main(String[] args) {
        int i = lengthOfLastWord("Hello World");

    }

    public static int  lengthOfLastWord(String s) {

//        s.split("");
//        s.index;
//        s.
        int max = 0;
        int min = 0;
        int sum = 0;
        int index = s.length() - 1;

        int value = 0;


        if (s.endsWith(" ")) {
            while (' ' == s.charAt(index)){
                index--;
                sum++;
                if (sum == 1){
                    max = index;
                }
                if (sum == 2){
                    min = index + 2;
                }
            }
        } else {

        }

        if (sum == 2){
            value = max - min;
        }



        return s.length();
    }
}
